<template>
  <van-nav-bar
      fixed
      title="提交投诉"
      left-text="返回"
      left-arrow
      @click-left="onClickLeft"
  />
  <van-divider/>
  <van-divider/>
  <van-form @submit="onSubmit">
    <van-field
        v-model="order_id"
        name="订单号"
        label="订单号"
        placeholder="订单号"
        :rules="[{ required: true, message: '请填写订单号' }]"
    />
    <van-field
        v-model="description"
        rows="3"
        type="textarea"
        name="投诉内容"
        label="投诉内容"
        placeholder="投诉内容"
        :rules="[{ required: true, message: '请填写投诉内容' }]"
    />
    <div style="margin: 16px;">
      <van-button round block type="primary" native-type="submit">
        提交
      </van-button>
    </div>
  </van-form>
</template>

<script>

import {submitComplain} from "@/api/complain";
import {Toast} from "vant";

export default {
name: "SubmitComplain",
  data(){
    return {
      order_id:"",
      description:"",
    }
  },
  methods:{
    onClickLeft(){
      history.back()
    },
    onSubmit(){
      submitComplain(this.order_id,this.description).then((res)=>{
        Toast.success(res.msg);
        history.back()
      })
    }
  }

}
</script>

<style scoped>

</style>
